package com.dahuyou.action;

import com.dahuyou.domain.service.IMap2ObjGenerator;
import com.dahuyou.domain.service.Map2ObjGeneratorImpl;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.ui.Messages;

/**
 * map转对象action动作类
 */
public class Map2ObjAction extends AnAction {
    private IMap2ObjGenerator map2ObjGenerator = new Map2ObjGeneratorImpl();

    @Override
    public void actionPerformed(AnActionEvent event) {
        try {
            // 织入代码了
            map2ObjGenerator.doGenerate(event.getProject(), event.getDataContext(), event.getData(LangDataKeys.PSI_FILE));
        } catch (Exception e) {
            e.printStackTrace();
            Messages.showInfoMessage("错误：你可能没有正确复制源对象，比如复制Map map = new HashMap()中的Map map，或者光标没有放在目标对象", " 错误提示！");
        }
    }
}
